package br.com.pucrs.tcc.bd;

import org.hibernate.SQLQuery;
import org.hibernate.Session;

import br.com.pucrs.tcc.ed.Curso;
import br.com.pucrs.tcc.ed.OrdemPriorizacao;

public class OrdemPriorizacaoBD {

	private Session mSession;

	public OrdemPriorizacaoBD(Session session) {
		mSession = session;
	}

	public void insert(OrdemPriorizacao ordemPriorizacao) {
		mSession.save(ordemPriorizacao);
		mSession.flush();
	}
	
	public void deletePorCurso(Curso curso) {
		StringBuilder sql = new StringBuilder();
		sql.append("DELETE FROM ordem_priorizacao ");
		sql.append(" WHERE cursos_id = ? ");

		SQLQuery query = mSession.createSQLQuery(sql.toString());
		query.setInteger(0, curso.getId());

		query.executeUpdate();
		
	}


}
